package com.example.techstudy.preresearch.Demo1;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: ls
 * @date: 2022/4/13
 * @description:
 */
public abstract class AbstractBean<T> {

    protected T t;

    private static final Map<Integer,AbstractBean> BEAN_MAP = new HashMap<>();

    protected abstract int getType();

    public void doPlay(){
        // System.out.println(t.getClass());
    }

    @PostConstruct
    protected final void init(){
        BEAN_MAP.put(this.getType(),this);
    }

    public static AbstractBean getBean(Integer type){
        return BEAN_MAP.get(type);
    }
}
